const express = require('express');
const {
  register,
  login,
  refreshToken,
  logout,
  getMe,
  forgotPassword,
  resetPassword
} = require('../controllers/authController');
const { protect } = require('../middleware/authMiddleware');
const {
  validateRegister,
  validateLogin,
  validateResetPassword,
  validateConfirmResetPassword
} = require('../middleware/validationMiddleware');

const router = express.Router();

// 公开路由
router.post('/register', validateRegister, register);
router.post('/login', validateLogin, login);
router.post('/refresh', refreshToken);
router.post('/forgot-password', validateResetPassword, forgotPassword);
router.post('/reset-password', validateConfirmResetPassword, resetPassword);

// 受保护的路由
router.post('/logout', protect, logout);
router.get('/me', protect, getMe);

module.exports = router;